
var PageInit =function () {
    if(com_obj.userId&& com_obj.userId>0){
        message();
    }else{
        var httpUrl = window.location.href;
        //window.location.href = '/user/user_login.html?href='+httpUrl+'';
        window.location.href = '../user/user_login.html';
    }
};
//消息通知
function message() {
    $.ajaxHandler({
        model: function () {
            var obj = {};
            obj.userId = com_obj.userId;
            return obj;
        },
        visible: true,
        visibleTime: 500,
        approve: true,
        api: "yg_baijiaapp/pushMessage/getUserMessageList",
        success: function (result) {
            //console.log(result);
            if (result.code == 10000) {
                var data=result.data;
                if(data.length>0){
                    var html="";
                    $.each(data,function (index,item) {
                        html+='<li class="clearfix">';
                        if(item.type==0){//系统消息
                            html+='<div class="meg-pic"><img src="../images/message/system_message.png"/> </div>';
                        }else if(item.type==1){//钱包消息
                            html+='<div class="meg-pic"><img src="../images/message/my_purse.png"/> </div>';
                        }else if(item.type==2){//物流消息
                            html+='<div class="meg-pic"><img src="../images/message/logistics_inform.png"/> </div>';
                        }
                        html+=    '<a class="meg-tex" href="system_message.html?type='+item.type+'">';
                        if(item.type==0){//系统消息
                            html+=  '<div class="meg-tex-1"><p class="meg1-p1">系统消息</p><p class="meg1-p2">'+item.content+'</p></div>';
                        }else if(item.type==1){//钱包消息
                            html+=  '<div class="meg-tex-1"><p class="meg1-p1">我的钱包</p><p class="meg1-p2">'+item.content+'</p></div>';
                        }else if(item.type==2){//物流消息
                            html+=  '<div class="meg-tex-1"><p class="meg1-p1">物流消息</p><p class="meg1-p2">'+item.content+'</p></div>';
                        }
                        if(item.type==0||item.type==1||item.type==2){
                            html+='<div class="meg-tex-2"><p class="meg2-p1">'+item.recentlyTime+'</p>';
                        }
                        if(item.noReadNum>0){
                            html +='<span class="meg2-p2">'+item.noReadNum+'</span>';
                        }
                        html +='</div>';
                        html+=    '</a>';
                        html+=   '</li>';
                    });
                    $(".meg-content ul").append(html);
                }
            } else {
                $.toast("加载失败", "text");
            }
        }
    });
}